   1. package com.tutsplus.flash  
   2. {  
   3.     import camo.core.display.CamoDisplay;  
   4.       
   5.     import flash.text.TextField;  
   6.   
   7.     public class LabelComponent extends CamoDisplay  
   8.     {  
   9.           
  10.         protected static const FIRST_WORD:String = "Hello";  
  11.         protected var words:Array = new Array("World", "People", "Flash", "Flash Tuts");   
  12.         protected var label:TextField;  
  13.           
  14.         /** 
  15.          *  
  16.          * @return Total number of words. 
  17.          *  
  18.          */       
  19.         public function get totalWords():Number  
  20.         {  
  21.             return words.length;  
  22.         }  
  23.           
  24.         /** 
  25.          * Class Constructor. 
  26.          *  
  27.          */       
  28.         public function LabelComponent()  
  29.         {  
  30.             super();  
  31.             init();  
  32.         }  
  33.           
  34.         /** 
  35.          * Class init function 
  36.          *  
  37.          */       
  38.         protected function init():void  
  39.         {  
  40.             label = createTextField();  
  41.             addChild(label);  
  42.         }  
  43.           
  44.         /** 
  45.          *  
  46.          * @return TextField for displaying a message on. 
  47.          *  
  48.          */       
  49.         protected function createTextField():TextField  
  50.         {  
  51.             var tempTextField:TextField = new TextField();  
  52.                 tempTextField.selectable = false;  
  53.                   
  54.             return tempTextField;  
  55.         }  
  56.           
  57.         /** 
  58.          * Changes a word based on an ID. 
  59.          * @param id index related to the words Array. 
  60.          *  
  61.          */       
  62.         public function changeWords(id:Number):void  
  63.         {  
  64.             label.text = FIRST_WORD + " " + words[id];  
  65.         }  
  66.   
  67.     }  
  68. }  